home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-06 | 1.4 KB | 49 lines | [TEXT/GEOL] |
- Item 1936340 2-July-90 00:43PDT
-
- From: D0532 Aidea Systems, Don Park,PRT
-
- To: CPLUS.DEV$ C++ Interest List--Developers
- CPLUS.APPLE$ C++ Interest List--Apple Employees
-
- Sub: const volatile missing!!!
-
- Here is a difference between ANSI C and C++ 2.0 I didn't know about:
-
- ANSI C allows 'const' and 'volatile' to be used together to declare variables
- that only external processes can change.
-
- C++ 2.0 apparently does not allow this although there is no mention of this
- incompatiability in the latest manual (Annotated C++ Reference Manual).
-
- Example Code:
-
- const volatile int xCopyDone = 0; /* x is for external data */
- volatile const int xCopyError = 0; /* order has no effect */
-
- int
- WaitForCopy ( void )
- {
- while (!xCopyDone)
- Meditate();
- return xCopyError;
- }
-
- ANSI C will allocate xCopyDone and xCopyError as external data while C++ uses
- them as constants. Thus the code is translated into following:
-
- int
- WaitForCopy__Fv ( void ) /* mangley doodley */
- {
- while (1)
- Meditate__Fv();
- return (int)0;
- }
-
- Using 'extern' with initializer will allocate them but code is for
- WaitForCopy() is still the same over friendly puke.
-
- So, be aware and prosper if it can be implemented!
-
- Don Park
-
-